<template>
  <div>
    <h2>home</h2>
    items里面的num
    <button @click="addNum">点击增加items中的num</button>
    {{ $store.state.items.num }}
    {{ itemNum }}
    <hr />
    orders里面的num
    {{ $store.state.orders.num }}
    {{ orderNum }}
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
export default {
  mounted () {
    console.log(this.$store)
  },
  methods: {
    addNum () {
      // this['items/add_num'](100)
      this.add_num(50)
    },
    // ...mapMutations(['items/add_num'])
    ...mapMutations('items', ['add_num'])
  },
  computed: {
    ...mapState({
      itemNum: (state) => state.items.num,
      orderNum: (state) => state.orders.num
    })
  }
}
</script>

<style lang="scss" scoped>
</style>
